/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author chapmand
 */
@Entity
@Table(name = "DiscountCode")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "DiscountCode.findAll", query = "SELECT d FROM DiscountCode d"),
    @NamedQuery(name = "DiscountCode.findByDiscID", query = "SELECT d FROM DiscountCode d WHERE d.discID = :discID"),
    @NamedQuery(name = "DiscountCode.findByDiscName", query = "SELECT d FROM DiscountCode d WHERE d.discName = :discName"),
    @NamedQuery(name = "DiscountCode.findByDiscNum", query = "SELECT d FROM DiscountCode d WHERE d.discNum = :discNum")})
public class DiscountCode implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "DiscID")
    private Integer discID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 50)
    @Column(name = "DiscName")
    private String discName;
    @Basic(optional = false)
    @NotNull
    @Column(name = "DiscNum")
    private float discNum;
    @OneToMany(mappedBy = "discountCode")
    private Collection<Customer> customerCollection;
    @OneToMany(mappedBy = "sDisc")
    private Collection<Sales> salesCollection;
    @OneToMany(mappedBy = "psodisc")
    private Collection<PSOLines> psoLinesCollection;
    @OneToMany(mappedBy = "invPSOdisc")
    private Collection<InvPSOLines> invPSOLinesCollection;
    @OneToMany(mappedBy = "invSaleDisc")
    private Collection<InvSalesLines> invSalesLinesCollection;

    public DiscountCode() {
    }

    public DiscountCode(Integer discID) {
        this.discID = discID;
    }

    public DiscountCode(Integer discID, String discName, float discNum) {
        this.discID = discID;
        this.discName = discName;
        this.discNum = discNum;
    }

    public Integer getDiscID() {
        return discID;
    }

    public void setDiscID(Integer discID) {
        this.discID = discID;
    }

    public String getDiscName() {
        return discName;
    }

    public void setDiscName(String discName) {
        this.discName = discName;
    }

    public float getDiscNum() {
        return discNum;
    }

    public void setDiscNum(float discNum) {
        this.discNum = discNum;
    }

    @XmlTransient
    public Collection<Customer> getCustomerCollection() {
        return customerCollection;
    }

    public void setCustomerCollection(Collection<Customer> customerCollection) {
        this.customerCollection = customerCollection;
    }

    @XmlTransient
    public Collection<Sales> getSalesCollection() {
        return salesCollection;
    }

    public void setSalesCollection(Collection<Sales> salesCollection) {
        this.salesCollection = salesCollection;
    }

    @XmlTransient
    public Collection<PSOLines> getPSOLinesCollection() {
        return psoLinesCollection;
    }

    public void setPSOLinesCollection(Collection<PSOLines> psoLinesCollection) {
        this.psoLinesCollection = psoLinesCollection;
    }

    @XmlTransient
    public Collection<InvPSOLines> getInvPSOLinesCollection() {
        return invPSOLinesCollection;
    }

    public void setInvPSOLinesCollection(Collection<InvPSOLines> invPSOLinesCollection) {
        this.invPSOLinesCollection = invPSOLinesCollection;
    }

    @XmlTransient
    public Collection<InvSalesLines> getInvSalesLinesCollection() {
        return invSalesLinesCollection;
    }

    public void setInvSalesLinesCollection(Collection<InvSalesLines> invSalesLinesCollection) {
        this.invSalesLinesCollection = invSalesLinesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (discID != null ? discID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DiscountCode)) {
            return false;
        }
        DiscountCode other = (DiscountCode) object;
        if ((this.discID == null && other.discID != null) || (this.discID != null && !this.discID.equals(other.discID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.DiscountCode[ discID=" + discID + " ]";
    }
    
}
